home *** CD-ROM | disk | FTP | other *** search
- /*
- ModelessSample - a sample application showing how to implement a
- modeless dialog with a couple of controls.
-
- Compiles with the PowerPC Universal interfaces for both 68K and
- PowerPC applications, which you can get from a Developer CD or AppleLink.
-
- In order to build this sample under MPW, you need to define PPCCincludes
- to point to the folder containing the Universal interfaces. And
- don't forget to drop the CodeFragmentTypes.r into your RIncludes
- directory, or Rez won't know what to do with 'cfrg's for PowerPC builds.
-
- Nitin Ganatra, Apple Developer Technical Support
- February 1994.
- */
-
- #ifndef __QUICKDRAW__
- #include <QuickDraw.h>
- #endif
-
- #ifndef __DIALOGS__
- #include <Dialogs.h>
- #endif
-
- #ifndef __FONTS__
- #include <Fonts.h>
- #endif
-
- #ifndef __PROCESSES__
- #include <Processes.h>
- #endif
-
- #ifndef __TEXTEDIT__
- #include <TextEdit.h>
- #endif
-
- #ifndef __MENUS__
- #include <Menus.h>
- #endif
-
- #ifndef __MEMORY__
- #include <Memory.h>
- #endif
-
- #ifndef __ERRORS__
- #include <Errors.h>
- #endif
-
- #ifndef __SCRAP__
- #include <Scrap.h>
- #endif
-
- #ifndef __TOOLUTILS__
- #include <ToolUtils.h>
- #endif
-
- #ifndef __WINDOWS__
- #include <Windows.h>
- #endif
-
- #ifndef __TEXTUTILS__
- #include <TextUtils.h>
- #endif
-
- enum {
- kMenuBarResID = 128,
- kAboutBoxDITLID = 128,
- kModelessDialogID = 200
- };
-
- enum {
- kOkayButton = 1,
- kCancelButton,
- kEditCheckItem,
- kEditTextField,
- kEditUserItem,
- kOkayUserItem
- };
-
- enum {
- kCutItem = 1,
- kCopyItem,
- kPasteItem,
- kClearItem,
- kAppleMenu = 128,
- kFileMenu,
- kEditMenu
- };
-
- enum {
- kNewItem = 1,
- kQuitItem
- };
-
- void InitApplication(void);
- void CreateNewWindow(void);
- void MainEventLoop(void);
- Boolean MenuCommand(long);
- void DoAboutBox(void);
- void PreEventLoop(void);
- void PostEventLoop(void);
- pascal void DrawWindowContent(short, short, GDHandle, long);
- void DrawIt(WindowPtr);
- void DoUpdate(WindowPtr);
- void AdjustMenus(void);
-
- Boolean EventFilter(EventRecord *theEvent, WindowPtr theFrontWindow);
- void CreateModelessDialog(void);
- void DoDialogEvent(EventRecord *);
- void DoDialogNullEvent(EventRecord *);
- void DoCut(DialogPtr);
- void DoCopy(DialogPtr);
- void DoPaste(DialogPtr);
- void DoClear(DialogPtr);
-
- static void HiliteAllControls(DialogPtr, short);
- static void DisableDialogControl(DialogPtr, short);
- static void SetDialogControlHilite(DialogPtr, short, Boolean);
- static ControlHandle GetCtlHandle(DialogPtr, short);
- static void InvalThisItemRect(DialogPtr, short);
- static void FakeButtonHilite(DialogPtr, short);
- static pascal void DrawButtonBorder(WindowPtr, short);
- static pascal void DimEditLine(WindowPtr, short);
-